<html>
<head><meta charset="utf-8"><title>why associated const of references requires specific life... · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html">why associated const of references requires specific life...</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212206515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212206515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212206515">(Oct 04 2020 at 05:14)</a>:</h4>
<p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=04612c15d74b5a43fc21c9b1dc407fb1">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=04612c15d74b5a43fc21c9b1dc407fb1</a><br>
The error message and suggestion are messed:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">error</span><span class="p">[</span><span class="n">E0106</span><span class="p">]</span>: <span class="nc">missing</span><span class="w"> </span><span class="n">lifetime</span><span class="w"> </span><span class="n">specifier</span><span class="w"></span>
<span class="w"> </span><span class="o">-</span>-&gt; <span class="nc">src</span><span class="o">/</span><span class="n">lib</span><span class="p">.</span><span class="n">rs</span>:<span class="mi">5</span>:<span class="mi">18</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">5</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">B</span>: <span class="kp">&amp;</span><span class="kt">str</span> <span class="o">=</span><span class="w"> </span><span class="s">"test"</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w">                  </span><span class="o">^</span><span class="w"> </span><span class="n">expected</span><span class="w"> </span><span class="n">named</span><span class="w"> </span><span class="n">lifetime</span><span class="w"> </span><span class="n">parameter</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="n">help</span>: <span class="nc">consider</span><span class="w"> </span><span class="n">introducing</span><span class="w"> </span><span class="n">a</span><span class="w"> </span><span class="n">named</span><span class="w"> </span><span class="n">lifetime</span><span class="w"> </span><span class="n">parameter</span><span class="w"></span>
<span class="w">  </span><span class="o">|</span><span class="w"></span>
<span class="mi">1</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">MyStruct</span><span class="p">;</span><span class="w"></span>
<span class="mi">2</span><span class="w"> </span><span class="o">|</span><span class="w"></span>
<span class="mi">3</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="k">impl</span><span class="w"> </span><span class="n">MyStruct</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="mi">4</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="nb">static</span> <span class="kt">str</span> <span class="o">=</span><span class="w"> </span><span class="s">"test"</span><span class="p">;</span><span class="w"></span>
<span class="mi">5</span><span class="w"> </span><span class="o">|</span><span class="w">     </span><span class="k">pub</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">B</span>: <span class="kp">&amp;</span><span class="o">'</span><span class="na">a</span> <span class="kt">str</span> <span class="o">=</span><span class="w"> </span><span class="s">"test"</span><span class="p">;</span><span class="w"></span>
</code></pre></div>



<a name="212211189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212211189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212211189">(Oct 04 2020 at 07:42)</a>:</h4>
<p>people also asked about that in <a href="https://www.reddit.com/r/rust/comments/j4qtnt/declare_a_constant_string/">https://www.reddit.com/r/rust/comments/j4qtnt/declare_a_constant_string/</a></p>



<a name="212214845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212214845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212214845">(Oct 04 2020 at 09:31)</a>:</h4>
<p>seems like a bug to me -- I'd expect associated consts to be treated like top-level consts here</p>



<a name="212214973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212214973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212214973">(Oct 04 2020 at 09:35)</a>:</h4>
<p>this bug has already been fixed on nightly afaict</p>



<a name="212215386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215386">(Oct 04 2020 at 09:47)</a>:</h4>
<p><span class="user-mention" data-user-id="216206">@lcnr</span>  doesn't seem like it: <a href="https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8adec37547e0449f0171f86b225007c7">https://play.rust-lang.org/?version=nightly&amp;mode=debug&amp;edition=2018&amp;gist=8adec37547e0449f0171f86b225007c7</a></p>



<a name="212215404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215404">(Oct 04 2020 at 09:48)</a>:</h4>
<p>both of these suggestions are correct though?</p>



<a name="212215447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215447">(Oct 04 2020 at 09:48)</a>:</h4>
<p>I would expect this to compile</p>



<a name="212215450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215450">(Oct 04 2020 at 09:48)</a>:</h4>
<p>without errors</p>



<a name="212215458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215458">(Oct 04 2020 at 09:49)</a>:</h4>
<p>after all the same thing compiles when moving the const out of the <code>impl</code> block</p>



<a name="212215469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215469">(Oct 04 2020 at 09:49)</a>:</h4>
<p>I don't think we allow elided lifetimes in associated consts</p>



<a name="212215477"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215477" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215477">(Oct 04 2020 at 09:49)</a>:</h4>
<p>right, and the question <span class="user-mention" data-user-id="209117">@lzutao</span> raised was "why"</p>



<a name="212215485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215485">(Oct 04 2020 at 09:49)</a>:</h4>
<p>seems rather arbitrary to only allow this for top-level consts</p>



<a name="212215539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215539">(Oct 04 2020 at 09:50)</a>:</h4>
<blockquote>
<p>seems like a bug to me<br>
and</p>
</blockquote>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="w"> </span><span class="o">&lt;'</span><span class="na">a</span><span class="o">&gt;</span><span class="k">pub</span><span class="w"> </span><span class="k">struct</span> <span class="nc">MyStruct</span><span class="p">;</span><span class="w"></span>
</code></pre></div>

<p>was what I replied to <span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span></p>



<a name="212215544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215544">(Oct 04 2020 at 09:50)</a>:</h4>
<p>the title of this thread is</p>
<blockquote>
<p>why associated const of str require 'static ?</p>
</blockquote>



<a name="212215545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215545">(Oct 04 2020 at 09:50)</a>:</h4>
<p>for associated consts lifetime other than static make sense</p>



<a name="212215548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215548">(Oct 04 2020 at 09:50)</a>:</h4>
<p>at least that might have been one of the concerns</p>



<a name="212215557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215557">(Oct 04 2020 at 09:51)</a>:</h4>
<p>otherwise we probably didn't have anyone push for this before <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="212215630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215630">(Oct 04 2020 at 09:52)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120791">RalfJ</span> <a href="#narrow/stream/122651-general/topic/why.20associated.20const.20of.20str.20require.20'static.20.3F/near/212215544">said</a>:</p>
<blockquote>
<p>the title of this thread is</p>
<blockquote>
<p>why associated const of str require 'static ?</p>
</blockquote>
</blockquote>
<p>yeah, and associated const of str does not require static. <code>const N: &amp;'a str</code> is also allowed</p>



<a name="212215644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215644">(Oct 04 2020 at 09:53)</a>:</h4>
<p>the title was not as clear to me as you think it should have been</p>



<a name="212215726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215726">(Oct 04 2020 at 09:55)</a>:</h4>
<p>yeah, I'm sorry. We have limits on title length so I wrote it a little ambiguous.<br>
I thought that all constants have the same 'static lifetime, so what I asked was<br>
why 'static omitted in normal constants, but have to be specified in associated consts ?</p>



<a name="212215842"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212215842" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212215842">(Oct 04 2020 at 09:58)</a>:</h4>
<p>(changed the topic title)</p>



<a name="212217899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212217899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212217899">(Oct 04 2020 at 10:54)</a>:</h4>
<blockquote>
<p>yeah, I'm sorry. We have limits on title length so I wrote it a little ambiguous.</p>
</blockquote>
<p>When writing the body of the message, just assume that nobody reads the title and explain everything in the body. There you also have enough space :)</p>



<a name="212228788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212228788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212228788">(Oct 04 2020 at 15:57)</a>:</h4>
<blockquote>
<p>It was also pointed out that while <code>'static</code> is a good default for statics and constants, it is not such a good choice for <strong>associated</strong> constants, which still require a fully explicit type (seems fine).</p>
</blockquote>
<p><a href="https://github.com/rust-lang/rfcs/pull/1623#issuecomment-239559757">https://github.com/rust-lang/rfcs/pull/1623#issuecomment-239559757</a></p>



<a name="212228873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212228873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212228873">(Oct 04 2020 at 15:59)</a>:</h4>
<p>Open issue about defaulting to <code>'static</code> in associated constants as well - <a href="https://github.com/rust-lang/rust/issues/51370">https://github.com/rust-lang/rust/issues/51370</a>.</p>



<a name="212229663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212229663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212229663">(Oct 04 2020 at 16:18)</a>:</h4>
<p>If the <code>impl</code> block does not introduce any lifetimes, then defaulting to <code>'static</code> would be a sensible default. But if lifetime params are in scope, then I think omitting the lifetime should cause an error pointing to at least one non-<code>'static</code> lifetime parameter in scope and asking to disambiguate between <code>'static</code> and that one.</p>
<p>That seems like a win-win situation <em>w.r.t.</em> the current situation:</p>
<ul>
<li>
<p>in the basic cases, it does the Right Thing unambiguously,</p>
</li>
<li>
<p>in the others, it still fails but with a more informative error message.</p>
</li>
</ul>



<a name="212237660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212237660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212237660">(Oct 04 2020 at 19:26)</a>:</h4>
<p>Hmm, I wonder how that interacts with the ideas in <a href="https://github.com/rust-lang/rfcs/pull/2548">https://github.com/rust-lang/rfcs/pull/2548</a> -- notably we don't default to <code>'static</code> for <code>fn(int)-&gt;&amp;str</code> either.</p>



<a name="212239273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/why%20associated%20const%20of%20references%20requires%20specific%20life.../near/212239273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matt1992 <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/why.20associated.20const.20of.20references.20requires.20specific.20life.2E.2E.2E.html#212239273">(Oct 04 2020 at 20:07)</a>:</h4>
<p>I mentioned how a <code>const FOO: &amp;BAR&lt;T&gt;</code> associated constant can't have a static lifetime without requiring <code>T: 'static</code> in this comment: <a href="https://github.com/rust-lang/rust/issues/51370#issuecomment-703297429">https://github.com/rust-lang/rust/issues/51370#issuecomment-703297429</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>